package com.nhjf.dao.system;

import org.hibernate.Criteria;
import org.hibernate.criterion.Restrictions;
import org.springframework.stereotype.Repository;

import com.nhjf.dao.BaseDao;
import com.nhjf.model.system.AdminSession;
import com.nhjf.pojo.qo.system.AdminSessionQo;

@Repository("adminSessionDao")
public class AdminSessionDao extends BaseDao<AdminSession, AdminSessionQo> {

	@Override
	protected Criteria buildCriteria(Criteria criteria, AdminSessionQo qo) {
		if(qo != null) {
			if(qo.getToken() != null) {
				criteria.add(Restrictions.eq("token", qo.getToken()));
			}
			
			if(qo.getLoginName() != null) {
				criteria.add(Restrictions.eq("loginName", qo.getLoginName()));
			}
		}
		return criteria;
	}

	@Override
	protected Class<AdminSession> getEntityClass() {
		return AdminSession.class;
	}
	

}
